package org.itworks.biodev.model;

import java.sql.*;

import org.itworks.helpers.*;

public class BiodevDatabase {
	
	private static HsqlDbConnection connection = null;
	
	public BiodevDatabase() {
		
		// R�cup�rer dans fichier conf
		String username = "";
		String password = "";
		String database = "";
		
		
		
	}
	
	public static Connection getConnection() throws Exception {
		if(connection == null) {
			connection = new HsqlDbConnection("biodev","vedoib","BioDevDatabase");
		}
		
		return connection.getHandle();
	}
	
	public static void commit() {
		
		try {
			Statement st;
			st = getConnection().createStatement();
			st.execute("COMMIT");
			st.close();
		} catch (SQLException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		} catch (Exception e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
		
	}
	
	public static void close() {
		try {
			Statement st = getConnection().createStatement();
			st.execute("SHUTDOWN");
			getConnection().close();
		} catch(Exception e) {
			e.printStackTrace();
		}
	}
}
